﻿using System;
using System.Collections.Generic;
using System.Text;

using Spring.Transaction.Interceptor;

using efish.Framework.Model;
using efish.Framework.Dao;

namespace efish.Framework.Service
{
    public class MemberService : BaseService,IMemberService
    {
        private MembersDAO _membersDAO;
        public MembersDAO MembersDAO
        {
            get
            {
                return _membersDAO;
            }
            set
            {
                _membersDAO = value;
            }
        }

        [Transaction(ReadOnly = false)]
        public void CreateMember(Member item)
        {
            _membersDAO.Save(item);
        }
        [Transaction(ReadOnly = false)]
        public void UpdateMember(Member item)
        {
            _membersDAO.Update(item);
        }
        [Transaction(ReadOnly = false)]
        public void DeleteNewsMember(Member item)
        {
            _membersDAO.Delete(item);
        }
        [Transaction(ReadOnly = false)]
        public void DeleteMemberByID(int id)
        {
            _membersDAO.DeleteByID(id);
        }

        public Member GetByID(int id)
        {
            return _membersDAO.Get(id);
        }
        public IList<Member> GetMembers()
        {
            return _membersDAO.GetAll();
        }

        public Member GetMember(string email, string pwd)
        {
            return _membersDAO.GetMember(email, pwd);
        }
        public Member GetMember(string email)
        {
            return _membersDAO.GetMember(email);
        }
    }

    public interface IMemberService
    {
        void CreateMember(Member item);
        void UpdateMember(Member item);
        void DeleteNewsMember(Member item);
        void DeleteMemberByID(int id);

        Member GetByID(int id);
        IList<Member> GetMembers();

        // find methods
        Member GetMember(string email, string pwd);
        Member GetMember(string email);
    }
}
